import request from '../service/service';

/**
 * 获取全部模块列表
 * @param data {Object} 请求参数
 */
export function getModuleList(data) {
  return request({
    protocol: 'project/module_list',
    options: data
  });
}

/**
 * 获取所选项目的模块列表
 * @param data {Object} 请求参数 "project_id": 项目ID 必填
 */
export function getProjectModuleList(data) {
  return request({
    protocol: 'project/project_module_list',
    options: data
  });
}

/**
 * 更新所选项目的模块列表
 * @param data {Object} 请求参数
 * project_id: 必填 需要更新项目的ID
 * module_id_list: []  必填 更新后的模块ID列表
 */
export function updateProjectModule(data) {
  return request({
    protocol: 'project/update_project_module',
    options: data
  });
}

/**
 * 获取所选项目的数据源配置
 * @param data {Object} 请求参数
 * project_id: "" 项目ID 必填
 */
export function getDataSourceConfig(data) {
  return request({
    protocol: 'data_source/get_data_source_configuration_list',
    options: data
  });
}

/**
 * 更新所选项目的数据源的数据
 * @param data {Object} 请求参数
 * { data: [{
 *  project_id: "", 项目ID，必填
 *  data_source_name: "", 数据源名称，必填
 *  interface_type: "222200", 接口模式，选填
 *  url: "http://localhost", 接口地址，选填
 *  port: '' 端口，选填
 * }]}
 */
export function updateDataSourceConfig(data) {
  return request({
    protocol: 'data_source/update_data_source_configuration',
    options: data
  });
}

/**
 * 获取所选数据源名称的接口模式下拉菜单
 * @param data {Object} 请求参数
 * data_source_name: "摄像头" 数据源名称 必填
 */
export function getInterfaceType(data) {
  return request({
    protocol: 'data_source/get_interface_type_list',
    options: data
  });
}

/**
 * 获取项目列表
 */
export function getProjectList(data) {
  return request({
    protocol: 'bus/project/permission/getProjectList',
    options: data,
    method: 'get'
  });
}

/**
 * 获取项目列表
 */
export function getProjectListPage(data) {
  return request({
    protocol: 'bus/project/permission/getProjectListPage',
    options: data,
    method: 'get'
  });
}

/**
 * 获取项目用户
 */
export function getProjectUserList(data) {
  return request({
    protocol: 'bus/project/permission/get-projectUserList',
    options: data,
    method: 'get',
  });
}

/**
 * 项目批量添加/删除用户
 */
export function setProjectUser(data) {
  return request({
    protocol: 'bus/project/permission/set-projectUserList',
    options: data,
    method: 'post',
    hasQuery: true
  });
}

/**
 * 项目批量添加/删除用户
 */
export function updateProjectUser(data) {
  return request({
    protocol: 'bus/project/permission/set-projectUserListV2',
    options: data,
    method: 'post',
    hasQuery: true
  });
}

/**
 * 获取项目的菜单权限树
 */
export function getProjectTree(data) {
  return request({
    protocol: 'bus/project/permission/tree/permissions',
    options: data,
    method: 'get',
  });
}

/**
 * 根据项目id获取项目
 */
export function getByProjectId(data) {
  return request({
    protocol: 'bus/project/permission/getByProjectId',
    options: data,
    method: 'get',
  });
}

/**
 * 获取项目参建方
 */
export function getContractors(data) {
  return request({
    protocol: 'bus/contractors/findPage',
    options: data,
    method: 'get',
  });
}

/**
 * 获取项目参建单位
 */
export function getMulcontractors(data) {
  return request({
    protocol: 'bus/mulcontractors/findPage',
    options: data,
    method: 'get',
  });
}

/**
 * 删除项目参建单位
 */
export function delMulcontractors(data) {
  return request({
    protocol: 'bus/mulcontractors/deleteByIds',
    options: data,
    method: 'delete',
  });
}

/**
 * 新增项目参建单位
 */
export function addMulcontractors(data) {
  return request({
    protocol: 'bus/mulcontractors/create',
    options: data,
    method: 'post',
  });
}

/**
 * 修改项目参建单位
 */
export function updateMulcontractors(data) {
  return request({
    protocol: 'bus/mulcontractors/update',
    options: data,
    method: 'post',
  });
}

/**
 * 根据项目id删除项目
 */
export function delProject(data) {
  return request({
    protocol: 'bus/project/permission/delByProjectId',
    options: data,
    method: 'get',
  });
}

/**
 * 项目新增/修改
 */
export function projectSet(data) {
  return request({
    protocol: 'bus/project/permission/projectSet',
    options: data,
    method: 'post',
  });
}

/**
 * 删除项目参建方
 */
export function delContractors(data) {
  return request({
    protocol: 'bus/contractors/deleteByIds',
    options: data,
    method: 'delete',
  });
}

/**
 * 新增项目参建方
 */
export function addContractors(data) {
  return request({
    protocol: 'bus/contractors/create',
    options: data,
    method: 'post',
  });
}

/**
 * 修改项目参建方
 */
export function updateContractors(data) {
  return request({
    protocol: 'bus/contractors/update',
    options: data,
    method: 'post',
  });
}

/**
 * 项目菜单权限设置,支持新增/修改
 */
export function setProjectPermissions(data) {
  return request({
    protocol: 'bus/project/permission/set/permissions',
    options: data,
    method: 'post',
  });
}
